<?php
//App::import('Vendor','tcpdf/tcpdf');
App::import('Vendor','xtcpdf');
$tcpdf = new XTCPDF();
//$tcpdf = new XTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$textfont = 'helvetica';
 
//$tcpdf->SetAuthor("bachpt");
//$tcpdf->SetAutoPageBreak(true);

$tcpdf->setHeaderFont(array($textfont,'',20)); 
$tcpdf->xheadercolor = array(150,0,0); 
$tcpdf->xheadertext = 'Sponsors'; 
$tcpdf->xfootertext = 'Beaconschool. All rights reserved.'; 
 
$tcpdf->setPrintHeader(true);
$tcpdf->setPrintFooter(true);

// set default monospaced font
$tcpdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$tcpdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($textfont,'',7);
 
$tcpdf->AddPage();


 
// create some HTML content

foreach ($sponsors as $sponsor) {
$htmlcontent = <<<EOD
	<table border="0">
		<tr style="color: rgb(54,47,155); font-size: 9pt">
	        <td colspan="2" style="width: 35%"><b>{$sponsor['Sponsor']['sponsorName']}</b></td>
	        <td colspan="2" style="width: 35%"><b>{$sponsor['Sponsor']['website']}</b></td>
	        <td style="width: 30%"></td>
	    </tr>
	    <tr>
	        <td style="width: 10%"><b>Main Contact</b></td>
	        <td style="width: 25%">{$sponsor['Contact']['contactName']}</td>
	        <td style="width: 15%"><b>Marketing Contact</b></td>
	        <td style="width: 20%">{$sponsor['Sponsor']['maketingContact']}</td>
			<td style="width: 30%">{$sponsor['Contact']['address1']}</td>
	    </tr>
	    <tr>
	        <td><b>Main Phone</b></td>
	        <td>{$phone->format_phone($sponsor['Contact']['phone'])}</td>
	        <td><b>Marketing Phone</b></td>
	        <td>{$phone->format_phone($sponsor['Sponsor']['maketingPhone'])}</td>
			<td>{$sponsor['Contact']['address2']}</td>
	    </tr>
	    <tr>
	        <td><b>Main Email</b></td>
	        <td>{$sponsor['Contact']['email']}</td>
	        <td><b>Marketing Email</b></td>
	        <td>{$sponsor['Sponsor']['maketingEmail']}</td>
			<td>Aurora NE, 68220</td>
	    </tr>
		<tr>
			<td align="right">
				<b>Notes</b>
			</td>
			<td colspan="3">
				<table border="1">
					<tr>
						<td>{$sponsor['Sponsor']['note']}&nbsp;</td>
					</tr>
				</table>
			</td>
			<td>
				<table style="width:100%; font-size: 7pt; vertical-align: bottom">
					<tr>
						<td>
						</td>
						<td>
							Sponsor ID
						</td>
						<td align="right">
							{$sponsor['Sponsor']['id']}
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
EOD;
// output the HTML content
$tcpdf->writeHTML($htmlcontent, true, 0, true, 0);
$tcpdf->Cell(0, 0, '' ,'T',1,'L');
$htmlcontent2 = <<<EOD
	<table border="0">
		<tr>
	        <td align="center"><b>Aurora Public School ~ Msg provided by NebraskaLand Bank ~</b></td>
	    </tr>
	</table>
EOD;
$tcpdf->writeHTML($htmlcontent2, true, 0, true, 0);
$tcpdf->Cell(0, 0, '' ,'T',1,'C');
}

$tcpdf->Output('sponsors.pdf', 'D');
?>
